/**
* @name 左侧菜单组件
* @description:
* @param
* @return
*/

<template>
	<u-sticky z-index="1">
	<view class="leftMenu">

		
			<template v-if="exptxt">
				<view class="menuItem" v-for="(item,idx) of exptxt" :key="idx" @click="select(idx)" :class="{ weekActive: idx === current }">
					<!-- 套餐文字高亮显示 -->
					<view :class="changeText">
						<view>{{ item.name }}</view>
						<view>{{ item.price }}元/份</view>
					</view>
					
				</view>
			</template>

			<template v-else>
				暂无内容
			</template>
		
		<wyb-loading ref="loading"/>
	</view>
	</u-sticky>
</template>

<script>
	import * as api from '@/api/apiList/home.js';
	import {
		formDate
	} from '@/utils/formDate.js';

	export default {
		props:{
			exptxt:{
				
			}
		},
		data() {
			return {
				menus: "", //菜单数据
				enterprise: "", //企业数据
				// exptxt: "", //套餐列表
				current: 0, //当前选中项
			}
		},
		// watch: {
		// 	current: { //监听当前选中项
		// 		async handler(val) {
		// 			console.log(val)

		// 			this.$eventBus.$emit("selectExptxt", {
		// 				selectExptxt: this.exptxt[val],
		// 				menus: this.menus,
		// 				enterprise: this.enterprise
		// 			})
					
		// 		},
		// 		immediate: true
		// 	}
		// },
		methods: {
			// async API_list(day = formDate(new Date())) { //获取菜单接口
			// 	let result = {
			// 		param: {
			// 			day //日期 格式：yyyy-MM-dd
			// 		}
			// 	};
			// 	return await api.list(result);
			// },
			select(idx) { //切换套餐
				this.current = idx
				this.$emit("selectCurrent",idx)
			}
		},
		async created(){
			// this.$nextTick(()=>{
			// 	this.$refs.loading.showLoading() // 显示
			// })
			
			// let res = await this.API_list() //调用接口获取当天菜单
			// console.log(res)
			// this.menus = res.data.data.menus[0] //菜单数据
			// this.enterprise = res.data.data.enterprise //企业数据
			// this.exptxt = JSON.parse(this.menus.exptxt) //套餐列表
			
			// this.$eventBus.$emit("selectExptxt", {
			// 	selectExptxt: this.exptxt[this.current],
			// 	menus: this.menus,
			// 	enterprise: this.enterprise
			// })
			
			// this.$refs.loading.hideLoading() // 隐藏
		}
	}
</script>

<style lang="scss" scoped>
	.leftMenu {
		border: 1rpx solid #f8f1f1;
		border-top-right-radius: 25rpx;
		border-bottom-right-radius: 25rpx;
		overflow: hidden;
		margin-left: -5px;

		.menuItem {
			border-bottom: 1rpx solid #f8f1f1;
			padding: 30rpx;
			text-align: center;
			line-height: 40rpx;

			.menuTitle {
				display: block;
			}

			.menuPrice {
				display: block;
			}
		}
	}
	.weekActive {
			background: linear-gradient(#fde054, #ffc756);
			color: #ff0000;
		}
	.changeText {
			color: #f43a3d;
			text-align: center;
			line-height: 40rpx;
		}
</style>
